package jh.com.jhappbf.contract;

import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import jh.com.jhappbf.R;

/**
 * @author Administrator
 */
public class ContractManager extends Fragment implements OnClickListener {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.contract_main_activity, null);
        View view = inflater.inflate(R.layout.contract_main_activity, null);
        initView(view);
        return view;
    }

    /**
     * 初始化
     */
    private void initView(View v) {
        RelativeLayout mFinanceLayout = v.findViewById(R.id.verify_finance_layout);
        RelativeLayout mPriceLayout = v.findViewById(R.id.verify_control_layout);
        TextView mTxtFinance = v.findViewById(R.id.verify_finance_txt);
        TextView mTxtPrice = v.findViewById(R.id.verify_control_txt);
        RelativeLayout mPlanLayoutAdd = v.findViewById(R.id.verify_privilege_layout);
        TextView mTxtPlanAdd = v.findViewById(R.id.verify_privilege_txt);
        RelativeLayout mPriceLayoutAdd = v.findViewById(R.id.price_add_layout);
        TextView mPriceAddTxt = v.findViewById(R.id.price_add_txt);
        mFinanceLayout.setOnClickListener(this);
        mTxtFinance.setOnClickListener(this);
        mPriceLayout.setOnClickListener(this);
        mTxtPrice.setOnClickListener(this);
        mPlanLayoutAdd.setOnClickListener(this);
        mTxtPlanAdd.setOnClickListener(this);
        mPriceLayoutAdd.setOnClickListener(this);
        mPriceAddTxt.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.verify_finance_layout:
            case R.id.verify_finance_txt:
                Intent i = new Intent(getActivity(), ContractQuery.class);
                startActivity(i);
                break;
            case R.id.verify_control_layout:
            case R.id.verify_control_txt:
                Intent intent = new Intent(getActivity(), PriceQuery.class);
                startActivity(intent);
                break;
            case R.id.verify_privilege_layout:
            case R.id.verify_privilege_txt:
                Intent contractAddIntent = new Intent(getActivity(), ContractAdd.class);
                contractAddIntent.putExtra("flag", "add");
                startActivity(contractAddIntent);
                break;
            case R.id.price_add_layout:
            case R.id.price_add_txt:
                Intent priceIntent = new Intent(getActivity(), PriceAdd.class);
                priceIntent.putExtra("action", "add");
                startActivity(priceIntent);
            default:
                break;
        }

    }
}
